<?php
/**
 * 资金流水控制器
 * @author 孙银川
 * @date   2017.12.29
 */

namespace app\admin\controller;
use app\common\model\MoneyWater as MwModel;

class MoneyWater extends Base{

	/**
     * 流水列表(用户1、商户2、代理商3)
     */
	public function moneyList(){
		$label = input('get.label');
		// 查询条件
		$map = array();
		// 搜索
		if(input('get.act') == 's'){
			$data = input('post.');
			if($data['name']){
				if($data['label']) $map['m.mw_label'] = ['m.mw_label','=',$data['label']];
				switch($data['label']){
					// 商户
					case 2: $map['s.sp_name'] = ['s.sp_name','like','%'.$data['name'].'%'];break;
					// 代理商
					case 3: $map['a.agem_principals'] = ['a.agem_principals','like','%'.$data['name'].'%'];break;
					default: $map['u.nick_name'] = ['u.nick_name','like','%'.$data['name'].'%'];break;
				}
			}
		}else{
			if($label) $map['m.mw_label'] = ['m.mw_label','=',$label];
		}
		$mw = new MwModel();
		$money_list = $mw->enquiries(10,$map);

		$this->assign('page',$money_list->page);
		$this->assign('count',$money_list->count);
		$this->assign('money_list',$money_list->items());
		return $this->fetch('moneywater/moneyList');
	}

	/**
     * 流水详情
     */
	public function moneyDetail(){
		$id = input('get.id');
		$mw = new MwModel();
		if($id) $money = $mw->detail($id);

		$this->assign('money',$money);
		return $this->fetch('moneywater/moneyDetail');
	}
}